#pragma once
#include<iostream>
#include<string>
class Task{
    public:
        Task(int one=0,int two=0,char op=0)
            :_eleOne(one)
            ,_eleTwo(two)
            ,_operator(op){}
        int operator()(){
            return run();
        }

        int run(){
            int result=0;
            switch(_operator){
                case '+':
                    result=_eleOne+_eleTwo;
                    break;
                case '-':
                    result=_eleOne-_eleTwo;
                    break;
                case '*':
                    result=_eleOne*_eleTwo;
                    break;
                case '/':
                    if(_eleTwo==0)
                    {
                        std::cout<<"div error!"<<std::endl;
                        result=-1;
                    }
                    else
                    {
                        result=_eleOne/_eleTwo;
                    }
                    break;
                case '%':
                    if(_eleTwo==0)
                    {
                        std::cout<<"error!"<<std::endl;
                        result=-1;
                    }
                    else{
                        result=_eleOne%_eleTwo;
                    }
                    break;
                default:
                    std::cout<<"Wrong Input!"<<std::endl;
                    break;
            }
            return result;
        }

        int get(int* e1,int* e2,char* op)
        {
            *e1=_eleOne;
            *e2=_eleTwo;
            *op=_operator;
            return 0;
        }

    private:
        int _eleOne;
        int _eleTwo;
        char _operator;
};
